#ifndef MULTI_VIEW_COMBOBOX_H
#define MULTI_VIEW_COMBOBOX_H

#include <QComboBox>
#include <QVariant>
#include <QStyledItemDelegate>

class ComboBoxItemDelegate : public QStyledItemDelegate
{
	Q_OBJECT

public:
    ComboBoxItemDelegate(QObject *parent = nullptr);

	void setBackBrush(const QVariant& color)
	{
		m_backColor = color;
	}

protected:
	QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
	void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const;
	void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
	bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
	void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const;
	QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;


signals:
	void signal_btn_clicked(const QModelIndex& index);
private:
	QVariant m_backColor{ QVariant() };
	QPoint m_point{ QPoint(0, 0) };
};

class MultiViewComboBox : public QComboBox
{
    Q_OBJECT

public:
    using QComboBox::QComboBox;
    MultiViewComboBox(QWidget* parent = nullptr);
	void setData(const QVariant& data);

	QVariant data() const;

protected:
	void paintEvent(QPaintEvent* e) override;
    void hidePopup() override;
private:
	QString m_text{ QString() };
};

#endif // MULTI_VIEW_COMBOBOX_H
